package com.guochenglang.www.service;

import com.guochenglang.www.pojo.User;
import com.guochenglang.www.service.anotate.Affair;

import java.lang.reflect.InvocationTargetException;
import java.security.NoSuchAlgorithmException;
import java.sql.SQLException;
import java.util.ArrayList;


/**
 * @author 郭程朗
 */
public interface UserService {
    /**
     * 注册插入用户表
     *
     * @param user 注册的用户
     * @return 响应结果
     * @throws SQLException             sql异常
     * @throws InterruptedException     断点异常
     * @throws IllegalAccessException   非法访问异常
     * @throws InstantiationException   实现异常
     * @throws NoSuchAlgorithmException 没有元素异常
     */
    @Affair
    int signIn(User user) throws SQLException, InterruptedException, IllegalAccessException, NoSuchAlgorithmException, InstantiationException;

    /**
     * 修改密码/个人信息
     *
     * @param newPassword 修改后的用户密码
     * @param username    修改前的用户信息
     * @return 响应结果
     * @throws SQLException             sql异常
     * @throws InterruptedException     断点异常
     * @throws IllegalAccessException   非法访问异常
     * @throws InstantiationException   实现异常
     * @throws NoSuchAlgorithmException 没有元素异常
     */
    @Affair
    int changePassword(String newPassword, String username) throws SQLException, InterruptedException, IllegalAccessException, InstantiationException, NoSuchAlgorithmException;

    /**
     * 根据id获取具体用户
     *
     * @param id 用户id
     * @return 用户
     * @throws SQLException           sql异常
     * @throws InterruptedException   断点异常
     * @throws IllegalAccessException 非法访问异常
     * @throws InstantiationException 实现异常
     */
    User getUser(Integer id) throws SQLException, InterruptedException, IllegalAccessException, InstantiationException;

    /**
     * 更新用户信息
     *
     * @param userId 用户id
     * @param set    更新的数据
     * @return 更新的行数
     * @throws SQLException           sql异常
     * @throws InterruptedException   断点异常
     * @throws IllegalAccessException 非法访问异常
     * @throws InstantiationException 实现异常
     */
    @Affair
    int updateUser(Integer userId, User set) throws SQLException, InterruptedException, IllegalAccessException, InstantiationException;

    /**
     * 登录获得user对象
     *
     * @param user 登录信息
     * @return user对象
     * @throws SQLException             sql异常
     * @throws IllegalAccessException   非法访问异常
     * @throws InstantiationException   实现异常
     * @throws InterruptedException     断点异常
     * @throws NoSuchAlgorithmException 没有元素异常
     */
    User logIn(User user) throws SQLException, IllegalAccessException, InstantiationException, InterruptedException, NoSuchAlgorithmException;

    /**
     * 按条件获得用户
     *
     * @param condition 条件
     * @return 用户
     * @throws SQLException           sql异常
     * @throws InterruptedException   断点异常
     * @throws IllegalAccessException 非法访问异常
     * @throws InstantiationException 实现异常
     */
    ArrayList<User> getUser(User condition) throws SQLException, InterruptedException, IllegalAccessException, InstantiationException;
}
